<?php
/**
 * Created by PhpStorm.
 * User: acker
 * Date: 21-06-08
 * Time: 下午6:25
 */

namespace App\Models\yb;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;
use Encore\Admin\Traits\DefaultDatetimeFormat;


class UserModel extends Model
{
    use DefaultDatetimeFormat;

    use SoftDeletes;

    /**
     *
     *计量单位
     * @var string
     */
    protected $table = 'yb_user';

    /**
     * 主键
     *
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * 追加字段
     *
     * @var string
     */
    protected $appends = ['guests_promotion','action_id'];



    /**
     * 该模型是否被自动维护时间戳
     *
     * @var bool
     */
    public $timestamps = true;

    /**
     * @return mixed
     */
    public function getGuestsPromotionAttribute(){
        $guests_number = $this->guests_number;
        $promotion_number = $this->promotion_number;
        return $guests_number."/".$promotion_number;
    }

    /**
     * @return mixed
     */
    public function getActionIdAttribute(){
        return $this->id;
    }

    /**
     * @return array
     */
    protected function selectOptions(){
        $data_array =array();
        $data = self::get();
        foreach($data as $k=>$v){
            $data_array[$v['id']] = $v['nickname']."-".$v['phone'];
        }
        return $data_array;
    }

}
